<script type="text/javascript">
    $.extend({
        refresh_task_list:function() {
            if ($('#tabs_load').hasClass("event_load")) {
                $('#grid_task_table').trigger("reloadGrid");
    	}
        }
    });
    
    if (window.interval_task_list) {
    } else {
        window.interval_task_list = window.setInterval("$.refresh_task_list()", 100000);
    }

$(document).ready(function() {
    var initial_width ;
    $('#grid_task_table').jqGrid({
        url:'/task/grid',
        datatype: 'json',
        mtype: 'GET',
        colNames:['编号', '任务', '对象', '状态', '细节','开始时间', '结束时间'],
        colModel :[
            {name:'id', index:'id', width:5, align:'left'},
            {name:'name', index:'name', width:10, align:'left'},
            {name:'obj', index:'obj', width:10, align:'left'},
            {name:'status', index:'status', width:6, align:'left'},
            {name:'detail', index:'detail', width:30, align:'left'},
            {name:'created_at', index:'created_at', width:10, align:'left'},
            {name:'finished_at', index:'finished_at', width:10, align:'left'},
        ],
        rowNum:10,
        sortname:'id',
        sortorder:'desc',
        viewrecords: true,
        width: 1200,
        height:mainpanelHeight,
        autowidth:true,
        gridComplete:function(){
            jqgrid_page($(this), $("#div_grid_task_table"));   
            var ids=$(this).jqGrid('getDataIDs');
            for(var i=0; i<ids.length; i++){
                var name = $(this).getCell(ids[i], 'name');
                $(this).jqGrid('setRowData', ids[i], {name:SelfTranslate(name)});
            }            
        },
    });    
});
jqgrid_resize('#grid_task_table', '#div_grid_task_table'); 
</script>

<div class="panel panel-default">
    <div class="panel-body">
        <div class="item_toolsbar">
        </div>
        <div id="div_grid_task_table" >
        	<table id="grid_task_table"></table>
        </div>
    </div> <!--panel-body -->
</div>
